<extend name="Users:layout" />
<block name="content">
<script>
    function exchange(type){
        location.href=Think.U('Home/integral/index','integralType='+type);
    }
</script>
<style>
    .wst-account .yue{margin:20px;float:left;}
    .wst-account .tixian{float:left;margin:20px;}
    .wst-account .tixian #apply{width:100px;}
    .wst-account .chongzhi{float:left;margin:25px;}
    .wst-account .chongzhi #applylog{color:blue;}
    .wst-account{background-color: #fcfae2}
    .wst-details .zichan{font-size: 14px;margin:18px;}
    .wst-details .classify,.time{margin:16px;}
    .wst-details span{color:#999;padding-right:20px;}
    .wst-details a{padding-right:20px;}
    .wst-log th{background-color: #fcfae2}
    .wst-log td{text-align: center;border-bottom: 1px solid #aaa;height: 30px;}
</style>
    <div class="wst-body"> 
        <div class='wst-page-header'>买家中心 > 我的积分</div>
        <div class='wst-page-content'>
       	<div class='wst-account'>
            <div class="yue">
                您当前的积分：<span style="font-size: 20px;color:red">{$userScore}</span>分
            </div>
            <div class="tixian" >
                <button id="apply" class="wst-btn-query" onclick="exchange(0)">立即兑换好礼</button>
                <button id="apply" class="wst-btn-query" onclick="exchange(1)">立即抽中大奖</button>
            </div>
            <div class="chongzhi">
                <a id="applylog" href="{:U('Home/Articles/index/articleId')}">如何获得积分？</a>
            </div>
            <div class="wst-clear"></div>
        </div>
        <div>
            <div class='zichan'>最近30天记录</div>
        </div>
        <div class="wst-log">
            <table id="logInfo" cellspacing="0" width="100%">
               <thead>
                   <tr>
                        <th width='20%'>日期</th>
                        <th width='30%'>详情</th>
                        <th width='25%'>积分变更</th>
                        <th width='35%'>剩余积分</th>
                    </tr>
               </thead>
               <tbody>
                <volist name="pages['root']" key="key" id="record">
                    <tr>
                        <td><php>echo date('Y-m-d H:i:s',$record['time'])</php></td>
                        <td>
                            <if condition='$record["type"] eq 1'>下单成功
                                <elseif condition='$record["type"] eq 2'/>取消订单
                                <elseif condition='$record["type"] eq 3'/>充值
                                <elseif condition='$record["type"] eq 4'/>订单无效
                                <elseif condition='$record["type"] eq 5'/>活动
                                <elseif condition='$record["type"] eq 6'/>评价
                                <elseif condition='$record["type"] eq 7'/>
                                <if condition="$record['winningCode'] neq '' ">
                                    积分抽奖,中奖码：{$record['winningCode']}
                                <else />
                                    礼品兑换
                                </if>                           
                            </if>
                        </td>
                        <td><if condition="$record['IncDec'] eq 0"><span style="color:red">-{$record['score']}</span><else /><span style="color:green">+{$record['score']}</span></if></td>
                        <td>{$record['totalscore']}</td>
                    </tr>
                </volist>
               </tbody>
               <tr>
                <td colspan='8' align='center' style="height:30px;border-bottom: 0px;">
                    <div class="wst-page" style="float:right;padding-bottom:10px;">
                        <div id="wst-page-items">
                        </div>
                    </div>
                </td>
             </tr>
            </table>
        </div>
    </div>
        <script>
    <if condition="$pages['totalPage'] gt 1">
    $(document).ready(function(){
        laypage({
            cont: 'wst-page-items',
            pages: {$pages['totalPage']}, //总页数
            skip: true, //是否开启跳页
            skin: '#e23e3d',
            groups: 3, //连续显示分页数
            curr: function(){ //通过url获取当前页，也可以同上（pages）方式获取
                var page = location.search.match(/pcurr=(\d+)/);
                return page ? page[1] : 1;
            }(), 
            jump: function(e, first){ //触发分页后的回调
                if(!first){ //一定要加此判断，否则初始时会无限刷新
                    var nuewurl = WST.splitURL("pcurr");
                    var ulist = nuewurl.split("?");
                    if(ulist.length>1){
                        location.href = nuewurl+'&pcurr='+e.curr;
                    }else{
                        location.href = '?pcurr='+e.curr;
                    }
                    
                }
            }
        });
    });
    </if>
    </script>
</block> 